package org.jeecg.modules.nurse_user_bill.service.impl;

import org.jeecg.modules.nurse_user_bill.entity.NurseUserBill;
import org.jeecg.modules.nurse_user_bill.entity.NurseUserBillDetail;
import org.jeecg.modules.nurse_user_bill.entity.NurseUserBillInvoice;
import org.jeecg.modules.nurse_user_bill.mapper.NurseUserBillDetailMapper;
import org.jeecg.modules.nurse_user_bill.mapper.NurseUserBillInvoiceMapper;
import org.jeecg.modules.nurse_user_bill.mapper.NurseUserBillMapper;
import org.jeecg.modules.nurse_user_bill.service.INurseUserBillService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.io.Serializable;
import java.util.List;
import java.util.Collection;

/**
 * @Description: 用户发票
 * @Author: jeecg-boot
 * @Date: 2024-06-04
 * @Version: V1.0
 */
@Service
public class NurseUserBillServiceImpl extends ServiceImpl<NurseUserBillMapper, NurseUserBill> implements INurseUserBillService {

    @Autowired
    private NurseUserBillMapper nurseUserBillMapper;
    @Autowired
    private NurseUserBillDetailMapper nurseUserBillDetailMapper;
    @Autowired
    private NurseUserBillInvoiceMapper nurseUserBillInvoiceMapper;

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void delMain(String id) {
        nurseUserBillDetailMapper.deleteByMainId(id);
        nurseUserBillInvoiceMapper.deleteByMainId(id);
        nurseUserBillMapper.deleteById(id);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void delBatchMain(Collection<? extends Serializable> idList) {
        for (Serializable id : idList) {
            nurseUserBillDetailMapper.deleteByMainId(id.toString());
            nurseUserBillInvoiceMapper.deleteByMainId(id.toString());
            nurseUserBillMapper.deleteById(id);
        }
    }

}
